/*
 * Copyright
 */
package org.apache.ibatis.reflection.factory;

import java.util.List;
import java.util.Properties;

/**
 * mybatis 使用 ObjectFactory 创建所有需要的 object
 *
 * @author ztkool
 * @since 1.0.0
 */
public interface ObjectFactory {

    default void setProperties(Properties properties) {
        // NOP
    }

    /**
     * 使用默认构造创建对象实体
     *
     * @param type
     * @param <T>
     * @return
     */
    <T> T create(Class<T> type);

    /**
     * 使用特定参数的构造器创建对象实体
     *
     * @param type
     * @param constructorArgTypes
     * @param constructorArgs
     * @param <T>
     * @return
     */
    <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs);

    /**
     * Returns true if this object can have a set of other objects.
     * It's main purpose is to support non-java.util.Collection objects like Scala collections.
     *
     * @param type Object type
     * @return whether it is a collection or not
     * @since 3.1.0
     */
    <T> boolean isCollection(Class<T> type);

}
